<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/jquery-1.12.4.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/axios-0.18.0.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/antd.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="css/antd.css" />
		<script src="js/bootstrap.js" type="text/javascript" charset="utf-8"></script>
		<link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
		
		<style type="text/css">
			tr{
				height: 50px;
			}
		</style>
	</head>
	<body>
		<div id="app">
			<div style="background: #BFBFBF; height: 50px;font-size: 20px;line-height: 50px;padding-left: 50px;">
				管理编辑
			</div>
		<table border="0px" style="margin: auto;width: 80%;margin-top: 50px;">
			<tr>
				<td style="width: 15%;text-align: right;"><span style="color: red;">*</span>管理员：&nbsp;&nbsp;&nbsp;&nbsp;</td>
				<td style="width: 70%;"><input type="text" name="" id="supername" :value="supername" style="width: 100%;"/></td>
			</tr>
			<tr>
				<td style="width: 15%;text-align: right;"><span style="color: red;">*</span>密码：&nbsp;&nbsp;&nbsp;&nbsp;</td>
				<td style="width: 70%;"><input type="password" name="" id="superpassword" :value="superpassword" style="width: 100%;"/></td>
			</tr>
			<tr>
				<td style="width: 15%;text-align: right;"><span style="color: red;">*</span>手机：&nbsp;&nbsp;&nbsp;&nbsp;</td>
				<td style="width: 70%;"><input type="text" name="" id="phone" :value="superpassword" style="width: 100%;"/></td>
			</tr>
			<tr>
				<td style="width: 15%;text-align: right;"><span style="color: red;">*</span>邮箱：&nbsp;&nbsp;&nbsp;&nbsp;</td>
				<td style="width: 70%;"><input type="email" name="" id="email" :value="email" style="width: 100%;"/></td>
			</tr>
			<tr>
				<td style="width: 15%;text-align: right;"></td>
				<td style="width: 70%;">
					<span style="background: skyblue;color: white;border-radius: 5px;text-align: center;width: 70px;height: 30px;line-height: 30px;" class="glyphicon glyphicon-picture" aria-hidden="true" @click="update()">保存</span>
					<span style="background: #BFBFBF;border-radius: 5px;text-align: center;width: 65px;height: 30px;line-height: 30px;display: inline-block;" onclick="window.location.href='user.html'">取消</span>
				</td>
			</tr>
			
		</table>
		
			
		</div>
	</body>
</html>
<script type="text/javascript">
	var vm=new Vue({
		el:"#app",
		data:{
			supername:"",
			superpassword:"",
			phone:"",
			email:"",
			date:"",
			superid:"",
			
		},
		//渲染数据之前
		beforeMount:function(){
			var _this=this;
			//获取传过来的gid类型
			_this.superid=window.location.href.split("?")[1].split("=")[1];
			
			
			axios({
				method:"POST",
				url:"http://localhost:8080/Blogs_demo/admin/findId/"+_this.superid,
				data:{},
				
			}).then(res=>{
				console.log(res.data);
				_this.supername=res.data.supername;
				_this.superpassword=res.data.superpassword;
				_this.phone=res.data.phone;
				_this.email=res.data.email;
				_this.date=res.data.date;
				_this.superid=res.data.superid;
			}).catch(err=>{
				
				alert("服务出错了!!")
			})
		},
		filters: {
				timeFormat: function(time) {
					var date = new Date(time);
	
					var strDate = date.getFullYear() + "-" + (date.getMonth()+1) + "-" + date.getDate() + "   " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds() ;
	
					return strDate;
	
				}
		},
		methods:{
			update:function(){
				if($("#supername").val()==""){
					alert("管理员名字不能为空！！！")
				}else{
				axios({
					method:"POST",
					url:"http://localhost:8080/Blogs_demo/admin/adminUpdate",
					data:{
						"supername":$("#supername").val(),
						"superpassword":$("#superpassword").val(),
						"phone":$("#phone").val(),
					    "email":$("#email").val(),
						
						
					
						
						"superid":this.superid,
					},
					
				}).then(res=>{
					console.log(res.data);
					window.location.href="Admin.html"
				}).catch(err=>{
					
					alert("服务出错了!!")
				})
				}
			}
			
			
		}
		
		
	})
</script>
